import { request } from "@/utils/service"
import type * as News from "./types"

/** 增 */
export function createNewsApi(data: News.CreateOrUpdateNewsRequestData) {
  return request({
    url: "news",
    method: "post",
    data
  })
}

/** 删 */
export function deleteNewsApi(id: string) {
  return request({
    url: `news/${id}`,
    method: "delete"
  })
}

/** 改 */
export function updateNewsApi(data: News.CreateOrUpdateNewsRequestData) {
  return request({
    url: "news/" + data.id,
    method: "put",
    data
  })
}

/** 查 */
export function getNewsApi(params: News.GetNewsRequestData) {
  return request<News.GetNewsResponseData>({
    url: "news",
    method: "get",
    params
  })
}

/** 查详情 */
export function getNewsDetailApi(id: string) {
  return request<News.GetNewResponeseDetailData>({
    url: `news/${id}`,
    method: "get"
  })
}
